package org.example.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.demo.model.bo.HelloWorldSetInputBO;
import org.example.demo.service.HelloWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "HelloWorld智能合约调用 Controller", tags = {"HelloWorld Apl"})
@RestController
@RequestMapping("hello")
public class HelloWorldController {
    @Autowired
    private HelloWorldService service;

    @ApiOperation(value = "SET 接口", notes = "SET 接口")
    @RequestMapping(value = "set", method = RequestMethod.GET)
    public String set(@RequestParam("n") String n) throws Exception {
        HelloWorldSetInputBO input = new HelloWorldSetInputBO(n);
        return service.set(input).getTransactionReceipt().getTransactionHash();
    }

    @ApiOperation(value = "GET 接口", notes = "GET 接口")
    @RequestMapping(value = "get", method = RequestMethod.GET)
    public String get() throws Exception {
        return service.get().getValues();
    }
}
